Clock: Introduce PSR-20 Clock Service
as src/Data
type
#4004
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
With this PR I would like to introduce a
PSR-20
compliantClock Service
. While I refactoredServices/Cron
I once again stumbled upontime()
anddate()
, which caused issues due to wrong usage/wrong assumptions when dealing withnow
(time()
relies onJanuary 1 1970 00:00:00 GMT
which is more or lessUTC
,date()
always relies ondate_default_timezone_set()
, this MUST NOT be mixed when storingnow
information or doing arithmetics when retrieving aY-m-d H:i:s
back from the persistence layer).In addition the usage of these functions posseses the same issues like accessing the global scope or other infrastructure without relying on
Dependency Injection
. Accessing thetime
ordate
is just another subtle way of “reaching out”, which makes it hard/impossible to test those methods.I would like to change this with this PR.
User Land
Perspective: See https://github.com/ILIAS-eLearning/ILIAS/pull/4004/files#diff-19ff14f8652abd51b667e794b4258fa8cc58e7845c95af91fbc8ac15f0a41f8aR411